package polymorphic;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2022/9/14 19:19
 */
public class Dog extends Animal{
    public Dog(String name, int age) {
        super(name, age);
    }
    public void eat() {
        System.out.println(this.name + "吃骨头");
    }
    public void bark(){
        System.out.println("汪汪~");
    }

    public static void main(String[] args) {
        Animal animal = new Dog("66",3);
        animal.eat();
        //要想访问Dog类中独有的属性和方法，就要向下转型，将animal引用的Dog类型对象还原为Dog类的引用
        //向下转型，将大类型的引用赋值为小类型的引用，需要强转
        Dog dog = (Dog)animal;
        dog.bark();
    }
}
